<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select :disabled="disabled" v-model="categoryStore.c1Id" @change="handler">
          <el-option
            v-for="item in categoryStore.c1Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select :disabled="disabled" v-model="categoryStore.c2Id" @change="handler2">
          <el-option
            v-for="item in categoryStore.c2Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select :disabled="disabled" v-model="categoryStore.c3Id" @change="handler3">
          <el-option
            v-for="item in categoryStore.c3Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import useCategoryStore from '@/store/modules/category'
const categoryStore = useCategoryStore()

onMounted(() => {
  getC1()
})

const getC1 = () => {
  categoryStore.getC1()
}
const handler = () => {
  categoryStore.clearC2()
  categoryStore.clearC3()
  categoryStore.getC2()
}
const handler2 = () => {
  categoryStore.clearC3()
  categoryStore.getC3()
}
const handler3 = () => {
}

defineProps(['disabled'])
</script>

<style scoped></style>
